---
keywords: ""
root: "/v5.1"
description: "Swift documentation for 'ExpressibleByBooleanLiteral'"
title: "ExpressibleByBooleanLiteral"
layout: "default"
---

<div class="intro-declaration"><code class="language-swift">protocol ExpressibleByBooleanLiteral</code></div><p>A type that can be initialized with the Boolean literals <code>true</code> and
<code>false</code>.</p>
<table class="standard"><tr><th id="conforming-types">Conforming Types</th><td><code class="inherits">Bool</code></td></tr><tr><th id="associatedtypes">Associated Types</th><td><span id="aliasesmark"></span><div class="declaration"><code class="language-swift">associatedtype BooleanLiteralType</code><div class="comment"></div></div></td></tr></table><div class="discussion comment"><p><code>Bool</code>, <code>DarwinBoolean</code>, <code>ObjCBool</code>, and <code>WindowsBool</code> are treated as
Boolean values. Expanding this set to include types that represent more than
simple Boolean values is discouraged.</p>
<p>To add <code>ExpressibleByBooleanLiteral</code> conformance to your custom type,
implement the <code>init(booleanLiteral:)</code> initializer that creates an instance
of your type with the given Boolean value.</p>
</div><h3>Initializers</h3><div id="init_booleanLiteral-a160439c4efba0b022c58febb62fb2d3" class="declaration"><a class="toggle-link" href="#comment-init_booleanLiteral-a160439c4efba0b022c58febb62fb2d3">init init(booleanLiteral:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init_booleanLiteral-a160439c4efba0b022c58febb62fb2d3"><p>Creates an instance initialized to the given Boolean value.</p>
<p>Do not call this initializer directly. Instead, initialize a variable or
constant using one of the Boolean literals <code>true</code> and <code>false</code>. For
example:</p>
<pre><code class="language-swift">let twasBrillig = true
</code></pre>
<p>In this example, the assignment to the <code>twasBrillig</code> constant calls this
Boolean literal initializer behind the scenes.</p>
<ul>
<li>Parameter value: The value of the new instance.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">init(booleanLiteral value: Self.BooleanLiteralType)</code></div></div>